package com.example.recordingpen_datacollection.config;

import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;  

@Service
public class RateLimitConfig {  
  
    private Map<String, Integer> pathToMaxRequests = new HashMap<>();  
  
    public void addRateLimit(String pathPattern, int maxRequests) {  
        pathToMaxRequests.put(pathPattern, maxRequests);  
    }  
  
    public Integer getMaxRequests(String path) {  
        for (Map.Entry<String, Integer> entry : pathToMaxRequests.entrySet()) {  
            if (path.matches(entry.getKey())) {  
                return entry.getValue();  
            }  
        }  
        return null; // 默认没有限制或者返回特定的默认值  
    }  
}